/**
 * @description: TODO
 * @author ljxds
 * @date 2024/7/31 14:22
 * @version 1.0
 */
package com.imagecollector.controller;

import com.imagecollector.common.R;
import com.imagecollector.domain.vo.CaptchaVo;
import com.imagecollector.domain.vo.LoginVo;
import com.imagecollector.domain.vo.WXLoginVO;
import com.imagecollector.service.IUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@Api(tags = "admin登录相关接口")
@RestController
@RequestMapping("/admin")
public class AdminLoginController {

    @Autowired
    private IUserService userService;

    @ApiOperation(value = "获取图形验证码")
    @GetMapping("login/captcha")
    public R getCaptcha() {
        CaptchaVo captcha = userService.getCaptcha();
        return R.success().data("data", captcha);
    }


    @PostMapping("login")
    @ApiOperation(value = "登录")
    public R login(@RequestBody LoginVo loginVo) {
        WXLoginVO wxLoginVO = userService.loginAdmin(loginVo);
        return R.success().data("data", wxLoginVO);
    }
}